<?php
	class CustomerBO 
	{   
		private $customer;

		function __construct($id = null)
		{
			if(isset($id))
				$this->customer=R::load('customer',$id);
			else
				$this->customer=R::dispense('customer');			
		}

                public function getID()
		{
			return $this->customer->id;
		}
                
		public function getName()
		{
			return $this->customer->first_name.' '.$this->customer->last_name;
		}
		
		public function getEmail()
		{
			return $this->customer->email;
		}
	
		
		public function getPhone()
		{
			return $this->customer->phone;
		}
		
		public function getAddress()
		{
			return $this->customer->address1.' '.$this->customer->address2.' '.$this->customer->city.' '.$this->customer->state.' India'.$this->customer->zip;
		}
		
                public function getOrderBOs($status)
                {
                    $orderbos=array();
                    $orders=$this->customer->withCondition('status = ?',array($status))->ownIsorder;                    
                    foreach ($orders as $key => $order)
                    {
                        array_push($orderbos, BOFactory::getOrderBO($order->id));
                    }
                    return $orderbos;
                }
                
                
                 public function __get($field) {
                      return $this->customer->$field;
                 }
		
		
	}